/*
 *  ASetting.cpp
 *  libavid
 *
 *  Created by Peter on 23.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#include "ASetting.h"
#include "AStream.h"
#include "AObjDoc.h"
#include "AAttrList.h"

A_IMPLEMENT_CLASS( 'ASET', ASetting, AObject );

void ASetting::readFromStream( AStream& str, const AObjDoc& objd )
{
	UInt8 v1, v2;
	
	// Read the version indicator
	str.readPod( v1 );
	str.readPod( v2 );
	
	// Check if the version is right
	TR_ASSERT( v1 == 0x02 );
	TR_ASSERT( v2 == 0x06 );
	
	// Read the data members
	_name = str.readString();
	_kind = str.readString();
	str.readPod( _attributes );
	str.readPod( _type );
	
	// Read the index of the AAttrList object in the enclosing AObjDoc.
	UInt32 attrListRef;
	str.readPod( attrListRef );
	
	// Find the AAttrList in the AObjDoc
	_attrList = objd.resolveRef< AAttrList >( attrListRef );
}

void ASetting::dump( std::ostream& str ) const
{
	str << "ASetting {" << std::endl;
	str << "\t_name: " << _name << std::endl;
	str << "\t_kind: " << _kind << std::endl;
	str << "\t_attributes: " << _attributes << std::endl;
	str << "\t_type: " << _type << std::endl;
	str << "\t_attrList: " << _attrList << std::endl;
	str << "}" << std::endl;
}